From c251818ca07029d02c5afaec09c30f0abac3d4b5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 13 Jul 2005 14:07:10 +0000 Subject: [PATCH] Don't keep the caches for unthemed directories in a separate list, instead 2005-07-13 Matthias Clasen * gtk/gtkicontheme.c (load_themes): Don't keep the caches for unthemed directories in a separate list, instead append them at the end of the dir_mtimes list, so that we can check them for staleness like the other caches. (#310221, Mark McLoughlin) --- ChangeLog | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ gtk/gtkicontheme.c | 45 +++++++++++++-------------------------------- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 28baeb6727..d99da1cc4e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2005-07-13 Matthias Clasen + * gtk/gtkicontheme.c (load_themes): Don't keep the caches + for unthemed directories in a separate list, instead append + them at the end of the dir_mtimes list, so that we can check + them for staleness like the other caches. (#310221, Mark + McLoughlin) + * configure.in: Check that we have a new enough Cairo. 2005-07-13 Robert Ögren diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 28baeb6727..d99da1cc4e 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,11 @@ 2005-07-13 Matthias Clasen + * gtk/gtkicontheme.c (load_themes): Don't keep the caches + for unthemed directories in a separate list, instead append + them at the end of the dir_mtimes list, so that we can check + them for staleness like the other caches. (#310221, Mark + McLoughlin) + * configure.in: Check that we have a new enough Cairo. 2005-07-13 Robert Ögren diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 28baeb6727..d99da1cc4e 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,11 @@ 2005-07-13 Matthias Clasen + * gtk/gtkicontheme.c (load_themes): Don't keep the caches + for unthemed directories in a separate list, instead append + them at the end of the dir_mtimes list, so that we can check + them for staleness like the other caches. (#310221, Mark + McLoughlin) + * configure.in: Check that we have a new enough Cairo. 2005-07-13 Robert Ögren diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index 74af659eee..97cf4f9c57 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -81,7 +81,6 @@ struct _GtkIconThemePrivate */ GList *themes; GHashTable *unthemed_icons; - GList *unthemed_icons_caches; /* Note: The keys of this hashtable are owned by the * themedir and unthemed hashtables. @@ -571,7 +570,6 @@ gtk_icon_theme_init (GtkIconTheme *icon_theme) priv->themes_valid = FALSE; priv->themes = NULL; priv->unthemed_icons = NULL; - priv->unthemed_icons_caches = NULL; priv->pixbuf_supports_svg = pixbuf_supports_svg (); } @@ -604,16 +602,6 @@ do_theme_change (GtkIconTheme *icon_theme) } } -static void -free_cache (gpointer data, - gpointer user_data) -{ - GtkIconCache *cache = (GtkIconCache *)data; - - if (cache) - _gtk_icon_cache_unref (cache); -} - static void blow_themes (GtkIconTheme *icon_theme) { @@ -627,13 +615,9 @@ blow_themes (GtkIconTheme *icon_theme) g_list_foreach (priv->dir_mtimes, (GFunc)free_dir_mtime, NULL); g_list_free (priv->dir_mtimes); g_hash_table_destroy (priv->unthemed_icons); - if (priv->unthemed_icons_caches) - g_list_foreach (priv->unthemed_icons_caches, free_cache, NULL); - g_list_free (priv->unthemed_icons_caches); } priv->themes = NULL; priv->unthemed_icons = NULL; - priv->unthemed_icons_caches = NULL; priv->dir_mtimes = NULL; priv->all_icons = NULL; priv->themes_valid = FALSE; @@ -1001,6 +985,8 @@ load_themes (GtkIconTheme *icon_theme) UnthemedIcon *unthemed_icon; IconSuffix old_suffix, new_suffix; GTimeVal tv; + IconThemeDirMtime *dir_mtime; + struct stat stat_buf; priv = icon_theme->priv; @@ -1018,18 +1004,21 @@ load_themes (GtkIconTheme *icon_theme) for (base = 0; base < icon_theme->priv->search_path_len; base++) { - GtkIconCache *cache; dir = icon_theme->priv->search_path[base]; - cache = _gtk_icon_cache_new_for_path (dir); + dir_mtime = g_new (IconThemeDirMtime, 1); + dir_mtime->cache = _gtk_icon_cache_new_for_path (dir); + dir_mtime->dir = g_strdup (dir); + if (g_stat (dir, &stat_buf) == 0 && S_ISDIR (stat_buf.st_mode)) + dir_mtime->mtime = stat_buf.st_mtime; + else + dir_mtime->mtime = 0; + + priv->dir_mtimes = g_list_append (priv->dir_mtimes, dir_mtime); - if (cache != NULL) - { - priv->unthemed_icons_caches = g_list_prepend (priv->unthemed_icons_caches, cache); + if (dir_mtime->cache != NULL) + continue; - continue; - } - gdir = g_dir_open (dir, 0, NULL); if (gdir == NULL) @@ -1357,14 +1346,6 @@ gtk_icon_theme_has_icon (GtkIconTheme *icon_theme, return TRUE; } - for (l = priv->unthemed_icons_caches; l; l = l->next) - { - GtkIconCache *cache = (GtkIconCache *)l->data; - - if (_gtk_icon_cache_has_icon (cache, icon_name)) - return TRUE; - } - if (g_hash_table_lookup_extended (priv->all_icons, icon_name, NULL, NULL)) return TRUE; -- 2.30.2